<template>
  <div class="header">
    <div class="content-wrapper">
      <div class="avatar">
        <img :src="seller.avatar" width="64" height="64"/>
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="description">
          {{seller.description}}/{{seller.deliveryTime}}分钟送达
        </div>
        <div v-if="seller.supports" class="support">
          <span class="icon" :class="classMap[seller.supports[0].type]"></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div v-if="seller.supports" class="num" @click="showDetail">
        <span>{{seller.supports.length}}</span>个<span class="icon-keyboard_arrow_right"></span>
      </div>
    </div>
    <div class="bulletin-wrapper" @click="showDetail">
      <span class="bulletin-icon"></span>
      <span class="bulletin-text">{{seller.bulletin}}</span>
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%"/>
    </div>
    <transition name="fade">
      <div v-show="detailShow" class="detail">
        <div class="detail-wrapper clearfix">
          <div class="detail-main">
            <h1 class="name">{{seller.name}}</h1>
            <div class="star-wrapper">
              <star :size="48" :score="seller.score"></star>
            </div>
            <div class="title-wrapper">
              <div class="line"></div>
              <div class="title">优惠信息</div>
              <div class="line"></div>
            </div>
            <ul v-if="seller.supports" class="supports">
              <li v-for="item in seller.supports" class="item-supports">
                <span class="icon" :class="classMap[item.type]"></span><span class="text">{{item.description}}</span>
              </li>
            </ul>
            <div class="title-wrapper">
              <div class="line"></div>
              <div class="title">商家公告</div>
              <div class="line"></div>
            </div>
            <div class="supports">{{seller.bulletin}}</div>
          </div>
        </div>
        <div class="detail-close" @click="hiddenDetail"><span class="icon-close"></span></div>
      </div>
    </transition>
  </div>
</template>

<script type="text/ecmascript-6">

  import star from 'components/star/star';

  export default{
    props: ['seller'],
    data: function () {
      return {
        detailShow: false
      };
    },
    methods: {
      showDetail: function () {
        this.detailShow = true;
      },
      hiddenDetail: function () {
        this.detailShow = false;
      }
    },
    created: function () {
      this.classMap = ['descrease', 'discount', 'special', 'invoice', 'guarantee'];
    },
    components: {
      star
    }
  };
</script>

<style lang="stylus" rel="stylesheet/stylus">

  @import "../../common/stylus/mixin";
  @import "../../common/stylus/icon";

  .header
    position: relative
    color: #fff
    background: rgba(7, 17, 27, 0.5)
    overflow: hidden
    .content-wrapper
      position: relative
      padding: 24px 12px 18px 24px
      font-size: 0
      z-index: 1
      .avatar
        display: inline-block
        vertical-align: top
      .content
        display: inline-block
        margin-left: 16px
        color: rgb(255, 255, 255)
        .title
          font-size: 16px
          font-weight: bold
          line-height: 18px
          .brand
            display: inline-block
            width: 30px
            height: 18px
            vertical-align: top
            bg-image('brand')
            background-size: 30px 18px
            background-repeat: no-repeat
          .name
            display: inline-block

        .description
          font-size: 12px
          margin-top: 8px
        .support
          font-size: 10px
          margin-top: 10px
          .icon
            display: inline-block
            width: 12px
            height: 12px
            margin-right: 4px
            background-size: 12px 12px
            background-repeat: no-repeat
            vertical-align: top
            &.descrease
              bg-image('decrease_1')
            &.discount
              bg-image('discount_1')
            &.guarantee
              bg-image('guarantee_1')
            &.invoice
              bg-image('invoice_1')
            &.special
              bg-image('special_1')
      .num
        position: absolute
        display: inline-block
        right: 12px
        bottom: 18px
        font-size: 10px
        line-height: 12px
        padding: 7px 8px
        background-color: rgba(0, 0, 0, 0.2)
        border-radius: 10px;
        .icon-keyboard_arrow_right
          vertical-align: middle
          margin-left: 2px
    .bulletin-wrapper
      position: relative
      height: 28px
      line-height: 28px
      background: rgba(7, 17, 27, 0.2)
      padding: 0 16px 0 12px
      white-space: nowrap
      overflow: hidden
      text-overflow: ellipsis
      z-index: 1
    .bulletin-icon
      display: inline-block
      width: 22px
      height: 12px
      bg-image('bulletin')
      background-size: 22px 12px
      background-repeat: no-repeat
      vertical-align: top
      margin-top: 7px
    .bulletin-text
      font-size: 10px
      margin: 0 4px
    .background
      position: absolute
      top: 0
      left: 0
      width: 100%
      height: 100%
      z-index: 0
      filter: blur(10px)
    .detail
      position: fixed
      top: 0
      left: 0
      z-index: 60
      width: 100%
      height: 100%
      background: rgba(7, 17, 27, 0.8)
      color: rgb(255, 255, 255)
      overflow: auto
      &.fade-enter-active, &.fade-leave-active
        transition: all .5s
      &.fade-enter, &.fade-leave
        opacity: 0
        background: rgba(7, 17, 27, 0)
      .detail-wrapper
        min-height: 100%
      .detail-main
        padding-bottom: 64px
      .name
        text-align: center
        padding: 64px 0 16px 0
        font-size: 16px
        font-weight: 700
        line-height: 16px
        text-align: center
      .detail-close
        position: relative
        width: 32px
        height: 32px
        margin: -64px auto 0 auto
        font-size: 32px
      .star-wrapper
        text-align: center
      .title-wrapper
        display: flex
        width: 80%
        margin: 28px auto 24px auto
        .line
          position: relative
          top: 6px
          flex: 1
          width: 0
          height: 0
          border-top: 1px solid rgb(255, 255, 255, 0.2)
        .title
          flex: 1
          text-align: center
          font-size: 14px
          padding: 0 12px
      .supports
        width: 80%
        margin: 0 auto 28px auto
        font-size: 12px
        color: rgb(255, 255, 255)
        line-height: 24px
      .icon
        display: inline-block
        width: 16px
        height: 16px
        margin-right: 6px
        background-size: 16px 16px
        background-repeat: no-repeat
        vertical-align: middle
        &.descrease
          bg-image('decrease_1')
        &.discount
          bg-image('discount_1')
        &.guarantee
          bg-image('guarantee_1')
        &.invoice
          bg-image('invoice_1')
        &.special
          bg-image('special_1')
</style>
